package o;

import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Paint.Style;
import android.graphics.PorterDuff.Mode;
import android.graphics.PorterDuffXfermode;
import android.graphics.RectF;
import android.graphics.drawable.Drawable.Callback;
import android.graphics.drawable.GradientDrawable;
import android.os.Build.VERSION;
import android.view.View;
import androidx.annotation.NonNull;

public class asv extends GradientDrawable {
    private int ˊ;
    private final RectF ˎ;
    private final Paint ˏ = new Paint(1);

    public asv() {
        ˊ();
        this.ˎ = new RectF();
    }

    private void ˊ() {
        this.ˏ.setStyle(Style.FILL_AND_STROKE);
        this.ˏ.setColor(-1);
        this.ˏ.setXfermode(new PorterDuffXfermode(Mode.DST_OUT));
    }

    public boolean ॱ() {
        return !this.ˎ.isEmpty();
    }

    void ॱ(float f, float f2, float f3, float f4) {
        if (f != this.ˎ.left || f2 != this.ˎ.top || f3 != this.ˎ.right || f4 != this.ˎ.bottom) {
            this.ˎ.set(f, f2, f3, f4);
            invalidateSelf();
        }
    }

    public void ॱ(RectF rectF) {
        ॱ(rectF.left, rectF.top, rectF.right, rectF.bottom);
    }

    public void ˎ() {
        ॱ(0.0f, 0.0f, 0.0f, 0.0f);
    }

    public void draw(@NonNull Canvas canvas) {
        ˋ(canvas);
        super.draw(canvas);
        canvas.drawRect(this.ˎ, this.ˏ);
        ॱ(canvas);
    }

    private void ˋ(@NonNull Canvas canvas) {
        Callback callback = getCallback();
        if (ˊ(callback)) {
            ((View) callback).setLayerType(2, null);
        } else {
            ˎ(canvas);
        }
    }

    private void ˎ(@NonNull Canvas canvas) {
        if (VERSION.SDK_INT >= 21) {
            this.ˊ = canvas.saveLayer(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight(), null);
            return;
        }
        this.ˊ = canvas.saveLayer(0.0f, 0.0f, (float) canvas.getWidth(), (float) canvas.getHeight(), null, 31);
    }

    private void ॱ(@NonNull Canvas canvas) {
        if (!ˊ(getCallback())) {
            canvas.restoreToCount(this.ˊ);
        }
    }

    private boolean ˊ(Callback callback) {
        return callback instanceof View;
    }
}
